const app=getApp()
const url=app.globalData.url
const url1 = app.globalData.url1
Page({

  /**
   * 页面的初始数据
   */
  data: {
    names: "售后",
    flag: true,
    orders:[1]
  },
  back() {
    wx.navigateBack(1)
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
   const that=this
    that.getOrders()

    wx.getSystemInfo({
      success: function (res) {
        var clientHeight = res.windowHeight,
          clientWidth = res.windowWidth,
          rpxR = 750 / clientWidth;
        var calc = clientHeight * rpxR - 180;
        console.log(calc)
        that.setData({
          winHeight: calc
        });
      }
    });
  },
  toOrder() {
    console.log("去下单")
    wx.navigateTo({
      url: '../index/index',
    })
  },
  baoxiu(e){
    wx.navigateTo({
      url: '../details/details?orderId='+e.currentTarget.dataset.id,
    })
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },
  // 查询订单
  getOrders() {
    const that = this
    var user = wx.getStorageSync('user')
    wx.request({
      url: url1+'/AfterSale/SelectSale',
      data: {
        usesAccount: user.wxUsersAccount
      },
      header: {
        'content-type': "application/json"
      },
      method: "get",
      success(res) {
        console.log('订单数据')
        console.log(res.data)
        if (res.data.length == 0) {

          that.setData({
            orders: [],
            noOrder: true
          })
        } else {
          that.setData({
            orders: res.data,
            noOrder: false
          })
        }
      }
    })
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})